package com.lysj.bhp.withdraw.controller;


import com.lysj.bhp.util.web.ParamUtil;
import com.lysj.bhp.util.web.Resp;
import com.lysj.bhp.withdraw.base.WithdrawContent;
import com.lysj.bhp.withdraw.domain.WithDraw;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("admin/withdraw_record")
public class WithdrawRecordController extends WithdrawContent {


    @GetMapping("/list") // 查看申请列表
    public Resp list(WithDraw model) {
        Specification specification = ParamUtil.createSpecification(model);
        List<WithDraw> withDrawList = withdrawRepository.findAll(specification, new Sort(Sort.Direction.DESC, "checkDate"));
        for (WithDraw withDraw : withDrawList) {
            withDraw.setActualAmount(withDraw.getAmount().subtract(withDraw.getFeeAmount()));
        }
        return new Resp(withDrawList);
    }
}
